package pro.shushi.pamirs.hr.api.model.biz;

import pro.shushi.pamirs.hr.api.model.major.DictionaryItem;
import pro.shushi.pamirs.hr.api.model.org.Department;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;

/**
 * 该模型演示使用数据库维护的字典及其使用方式
 *
 * 用数据表维护的数据作为数据字典的示例，参考ditProjectType
 */
@Model.model(ProjectInfo.MODEL_MODEL)
@Model(displayName = "项目信息", labelFields = "projectName")
@Model.Advanced(unique = {"projectCode"})
public class ProjectInfo extends IdModel {

    public static final String MODEL_MODEL = "hr.simple.ProjectInfo";

    @Field(displayName = "项目编码", required = true)
    public String projectCode;

    @Field(displayName = "项目名称", required = true)
    public String projectName;

    // **********************数据字典表达方式2（可维护的数据表）：用数据表维护的数据作为数据字典*************************************
    // 字段之关系描述特殊场景 参考：https://doc.oinone.top/oio4/9241.html
    // **********************数据字典表达方式1（枚举方式）：@see pro.shushi.pamirs.hr.api.model.org.Employee.level*************
    @Field.many2one
    @Field.Relation(relationFields = {"projectType", "#PT1500#"}, referenceFields = {"dictValue", "typeCode"}, domain = "typeCode=='PT1500'")
    @Field(displayName = "项目类型(数据表维护的字典)", summary = "示例是为了说明怎么用数据表维护的数据字典", required = true)
    private DictionaryItem ditProjectType;

    @Field(displayName = "项目类型Code", summary = "项目类型Code", invisible = true)
    private String projectType;

    @Field.many2one
    @Field.Relation(relationFields = {"departmentCode"}, referenceFields = {"code"})
    @Field(displayName = "所属部门", required = true)
    private Department department;

    @Field(displayName = "部门编码", invisible = true)
    private String departmentCode;

    @Field.Text
    @Field(displayName = "项目描述")
    private String remark;

}
